package app.netant.book.txt008;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class Txt008Detail extends BaseDetail {

	public Txt008Detail(String netSite) {
		super(netSite);
		this.preHref = "http://008txt.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".wrapper h1 a");
		if(parts.size()>0){
			String title = parts.get(0).text();
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
		
		Elements parts1 = this.select(".wrapper p a");
		if(parts1.size()>0){
			String writer = parts1.get(0).text();
			System.out.println("【Writer】:"+writer);
			this.entity.setNovelWriter(writer);
		}
	}

	@Override
	public void analyseTags() {
		
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".wrapper p");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			int st = memo.indexOf(".html");
			int ed = memo.indexOf("1.008txt");
			if(st>=0&& ed>=0 && ed>st){
				memo = memo.substring(st+5,ed);
			}
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".wrapper p a");
		for(int i=0;i<parts.size();i++){
			String txt = parts.get(i).text();
			if(txt.indexOf("下载")>=0){
				String href = parts.get(i).attr("href");
				System.out.println("【Href】:"+href);
				this.entity.setDownPath(href);
			}
		}
	}
	
	@Override
	public void analyseType() {
		
	}
	
	public static void main(String[] args) {
		Txt008Detail detail = new Txt008Detail("http://008txt.com/download/305276.html");
		detail.test();
	}



}
